package com.gongj.xml;

import com.gongj.annon.AppApplication;
import com.gongj.beanPostPorcessor.MeBeanPostPorcessor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

public class Main {

	public static void main1(String[] args) {
		ClassPathResource resource = new ClassPathResource("spring-config.xml");
		DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
		MeBeanPostPorcessor meBeanPostPorcessor = new MeBeanPostPorcessor();
		factory.addBeanPostProcessor(meBeanPostPorcessor);
		XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
		reader.loadBeanDefinitions(resource);
		Object person = factory.getBean("person");

		System.out.println(person);
	}

	public static void main(String[] args) {

		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
		Object person = context.getBean("person");

		System.out.println( "最终对象：" + person);

		context.close();
	}

	public static void main11(String[] args) {

		ApplicationContext context = new AnnotationConfigApplicationContext(AppApplication.class);
		Object person = context.getBean("person");

		System.out.println(person);


	}

}
